import axios from '@/utils/request';

/**
 * 手机号码登录/注册
 * 
 * @param {string} mobile 手机号码
 * @param {string} captcha 验证码
 * @return {Promise<any>}
 */
export function apiMobilelogin(mobile : string, captcha : string) : Promise<any> {
	return axios.post('/api/user/mobilelogin', { mobile, captcha })
}


/**
 * 用户信息
 * @return {Promise<any>}
 */
export function apiGetUserInfo() : Promise<any> {
	return axios.post('/api/user/userinfo')
}


/**
 * 修改手机号码
 * @param {requestChangeMobileInterface} data 
 * @return 
 */ 
export function apiChangeMobile(data:requestChangeMobileInterface) : Promise<any> {
	return axios.post('/api/user/changemobile', data)
}

/**
 * 修改昵称
 * @param {string} nickname 昵称
 * @return {Promise<any>}
 */ 
export function apiUpdateNickname(nickname : string) : Promise<any> {
	return axios.post('/api/user/updateNickname', { nickname })
}

/**
 * 修改头像
 * @param {string} avatar 头像地址
 * @return {Promise<any>} 
 */ 
export function apiUpdateAvatar(avatar:string):Promise<any>{
	return axios.post('/api/user/updateAvatar',{avatar})
}

/**
 * 退出登录
 * @return {Promise<any>} 
 */ 
export function apiLogout():Promise<any>{
	return axios.post('/api/user/logout')
}

interface CountInfoInterface{
	total_collection:number,
	total_music:number,
	total_play:number
}
/**
 * 用户统计
 * @return 
 */ 
export function apiGetMyCount():Promise<CountInfoInterface>{
	return axios.post('/api/user/myCount')
}